<template>
	<view class="my-store-info">

		<view class="addset" @tap="addSet">新增附加台卡</view>
		<view class="store-form" v-for="(item,index) in cardList" :key="index">
			<u-cell-group :border="false">
				<u-cell title="编号:" :border="false" :isLink="true" @click="setTerminal(item)">
					<view class="label" slot="value">{{item.qrCode}}</view>
				</u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	const globalData = app.globalData;
	const apiUrl = globalData.wxApi;
	const wxImg = globalData.wxImg;
	import {
		getStoreData,
		dealNum,
		httpPost,
		httpGet,
		bdMapToTxMap,
		txMapToBdMap,
	} from "@/utils/http.js";
	import mpMixin from "@/uni_modules/uview-ui/libs/mixin/mpMixin";
	import uQRCode from '@/common/uqrcode.js'
	const pic1 = require(`@/img/my/my1.png`);
	export default {
		data() {
			return {
				wxImg,
				apiUrl,
				dealNum,
				pic1,
				terminalInfo: {
					subStoreId: "",
					terminalId: "",
					storeId: ""
				},
				cardList: [],
				storeId:""


			};
		},

		onShow() {

		},
		onUnload() {

		},
		onLoad(options) {
			console.log(options)
			this.terminalInfo = JSON.parse(options.terminalInfo);
			this.storeId=options.storeId;
			this.getTerminalList();
		},
		methods: {
			getTerminalList() {
				const _this = this;
				httpGet(`/api/sellerstoreotherapply/additionalTerminalList/` + _this.terminalInfo.terminalId).then((
				res) => {
					if (res.code == 0) {
						_this.cardList = res.data;
					}
				});
			},
			addSet() {
				const _this = this;
				uni.scanCode({
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						let str = res.result;
						let index = str.indexOf("outpay/");
						let code = str.substring(index + 7);
						console.log(code);
						httpPost(`/api/sellerstoreotherapply/bindAdditionalTerminal`, {
							qrCode: Number(code),
							subStoreId: _this.terminalInfo.subStoreId,
							terminalId: _this.terminalInfo.terminalId,
							storeId: _this.terminalInfo.storeId
						}).then((res) => {
							uni.showToast({
								icon: "none",
								title: "绑定成功"
							});
							_this.getTerminalList();
						});
					}
				});
			},
			setTerminal(terminalInfo) {
				uni.navigateTo({
					url: "/pages/storeManage/deccaCodeSet?terminalInfo=" +JSON.stringify(terminalInfo)+"&storeId="+this.storeId
				});
			}


		},
	};
</script>

<style lang="scss">
	.my-store-info {
		background-color: #f4f5f7;
		height: calc(100vh - 20rpx);
		padding-top: 20rpx;
	}

	.head {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		background-color: #fff;
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-top: 20rpx;
		padding-bottom: 20rpx;

		.title {
			font-size: 32rpx;
			font-weight: 700;
		}
	}

	.store-form {
		background-color: #fff;
		padding-left: 30rpx;
		padding-right: 30rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}

	.show-box {
		width: 540rpx;
		padding: 30rpx;

		.title {
			font-size: 36rpx;
			text-align: center;
			font-weight: 600;
		}

		.tip {
			font-size: 24rpx;
			color: #AAAAAA;
			margin-top: 10rpx;
			margin-bottom: 20rpx;
		}

		.input-box {
			margin-top: 20rpx;
		}

		.sure {
			width: 200rpx;
			height: 70rpx;
			line-height: 70rpx;
			text-align: center;
			border-radius: 70rpx;
			background: linear-gradient(to right, #37AFFA, #74D6FF);
			color: #fff;
			margin-left: 170rpx;
			margin-top: 40rpx;
		}
	}

	.show-box-two {
		width: 570rpx;
		padding: 40rpx;
		border-radius: 10rpx;

		.code-box {
			width: 400rpx;
			height: 400rpx;
			border: 2rpx solid #f4f5f7;
			margin-top: 20rpx;
			margin-bottom: 20rpx;
			margin-left: 85rpx;
		}

		.tip {
			font-size: 24rpx;
			color: #AAAAAA;
		}

		.title {
			text-align: center;
		}
	}

	.addset {
		width: 690rpx;
		margin-left: 30rpx;
		background-color: #37AFFA;
		color: #fff;
		text-align: center;
		height: 70rpx;
		line-height: 70rpx;
		border-radius: 10rpx;
	}
</style>